const goods = require('../mongodb/goods')
const mongodb = require('../mongodb/index')

module.exports = function(){
    return (req,res)=>{
        const reg_classify = new RegExp(`${req.query.classify}`)
        mongodb.get(goods,{$and:[{name:eval('/'+req.query.keywords+'/')},{classify:reg_classify}]},(data)=>{
            res.send(JSON.stringify(data))
        },(err)=>{
            res.send(err)
        })
    }
}